/*kZime*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <algorithm>
#define MAXN 300233
using namespace std;
inline int read() {
	int k = 0, f = 1; char c = getchar();
	for(; !isdigit(c); c = getchar())if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
	return k * f;
}
/*-----------------------------------------------------------------------------*/

struct edge {
	int fr, to, ne;
	inline edge(){;}
	inline edge(int f, int t, int n) {
		fr = f;
		to = t;
		ne = n;
	}
}e[MAXN << 1];

int n, m, cnt, head[MAXN], d[MAXN], f[MAXN], ans;
bool vis[MAXN];

void add_edge(int fr, int to) {
	e[++cnt] = edge(fr, to, head[fr]), head[fr] = cnt, d[fr]++;
	e[++cnt] = edge(to, fr, head[to]), head[to] = cnt, d[to]++;
}

void dp(int now) {
	vis[now] = 1;
	int mx = 0, se = 0;
	for(int i = head[now];i; i = e[i].ne) {
		int to = e[i].to;
		if(vis[to])continue;
		dp(to);
		if(f[to] > mx) se = mx, mx = f[to];
		else if(f[to] > se) se = f[to];
	}
	f[now] = mx + d[now] - 1;
	ans = max(ans, se + f[now] + 1);
}

int main() {
#ifndef MYLAB
	freopen("worma.in", "r", stdin);
	freopen("worma.out", "w", stdout);
#else
//	freopen("in.txt", "r", stdin);
#endif

	n = read();
	m = read();
	for(int i = 1; i <= m; i++) add_edge(read(), read());
	
	dp(1);
	
	printf("%d", ans + 1);







	return 0;
}

